# -*- coding: utf-8 -*-
# @Time : 2021/9/12 12:17
# @Author : hello
# @Email : xxx@gmail.com
# @File : addcluebases_page.py
# @Project : crm
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from page.base_page import BasePage
from utils.util import HOST
class AddClueBases(BasePage):
    #
    # def __init__(self,driver):
    #     self.driver=driver

    url="{}/index.php?m=leads".format(HOST)
    #线索页面所有元素-添加
    clickadd=(By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(1) > div > a')
    fzr = (By.ID, 'owner_name')
    company = (By.ID, 'name')
    source = (By.ID, 'source')
    lxr = (By.ID, 'contacts_name')
    zw = (By.ID, 'position')
    phone = (By.ID, 'mobile')
    zc = (By.ID, 'saltname')
    yx = (By.ID, 'email')
    adress_x = (By.NAME, "address['state']")
    adress_s = (By.NAME, "address['city']")
    adress_q = (By.NAME, "address['area']")
    jd = (By.NAME, "address['street']")
    lxtimek = (By.ID, "nextstep_time")
    lxnr = (By.ID, 'nextstep')
    bz = (By.ID, 'description')
    bc = (By.CSS_SELECTOR, 'input[value="保存"]')
    #放入线索池
    xsc = (By.ID, 'remove')

    # 线索页面元素的所有输入
    def click_clue(self):
        """点击线索"""
        self.driver.find_element(*self.clickadd).click()

    def input_fxz(self, fxzs):
        """输入负责人"""
        ele = self.driver.find_element(*self.fzr)
        ele.clear()
        ele.send_keys(fxzs)

    def output_fxz(self):
        """清空负责人"""
        self.driver.find_element(*self.fzr).clear()

    def input_company(self, companys):
        """输入公司名称"""
        self.driver.find_element(*self.company).send_keys(companys)

    def select_source(self, sources):
        """选择来源"""
        ele = self.driver.find_element(*self.source)
        Select(ele).select_by_visible_text(sources)

    def input_lxr(self, lxrs):
        """输入联系人"""
        self.driver.find_element(*self.lxr).send_keys(lxrs)

    def input_zw(self, zws):
        """输入职位"""
        self.driver.find_element(*self.zw).send_keys(zws)

    def input_zc(self, zcs):
        """选择尊称"""
        ele = self.driver.find_element(*self.zc)
        Select(ele).select_by_visible_text(zcs)

    def input_phpne(self, phones):
        """输入电话"""
        self.driver.find_element(*self.phone).send_keys(phones)

    def input_yx(self, yxs):
        """输入邮箱"""
        self.driver.find_element(*self.yx).send_keys(yxs)

    def input_xadress(self, xadress):
        """选择省"""
        ele = self.driver.find_element(*self.adress_x)
        ele1 = Select(ele)
        ele1.select_by_visible_text(xadress)

    def input_sadress(self, sadress):
        """选择市"""
        ele = self.driver.find_element(*self.adress_s)
        ele2 = Select(ele)
        ele2.select_by_visible_text(sadress)

    def input_qadress(self, qadress):
        """选择区"""
        ele = self.driver.find_element(*self.adress_q)
        ele3 = Select(ele)
        ele3.select_by_visible_text(qadress)

    def input_jdadress(self, jdadress):
        """输入街道信息"""
        self.driver.find_element(*self.jd).send_keys(jdadress)

    def input_lxtime(self, lxtimes):
        """输入下次联系时间"""
        self.driver.find_element(*self.lxtimek).send_keys(lxtimes)

    def input_lxnr(self, lxtimes):
        """输入下次联系时间"""
        self.driver.find_element(*self.lxnr).send_keys(lxtimes)

    def input_bz(self, bzs):
        """输入备注"""
        self.driver.find_element(*self.bz).send_keys(bzs)

    def click_bc(self):
        """点击保存"""
        self.driver.find_element(*self.bc).click()

    def click_putclue(self):
        """点击放入线索池"""
        self.driver.find_element(*self.xsc).click()





